﻿using Mapster;
using MapsterMapper;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace AME.Mapper
{
    public static class RegisterMapper
    {
        public static IServiceCollection UseMapper(this IServiceCollection services)
        {
            // 配置 Mapster
            var config = TypeAdapterConfig.GlobalSettings;
            config.Scan(Assembly.Load("Model")); // 扫描程序集中的映射配置

            // 注册 Mapster 的配置和 Mapper 到 DI 容器
            services.AddSingleton(config);
            services.AddScoped<IMapper, ServiceMapper>();

            return services;
        }
    }
}
